using System;
using System.Configuration;

namespace PhotoGallery.Configuration
{
    public abstract class NamedConfigurationElementBase : System.Configuration.ConfigurationElement
    {
        private const string NameItem = "name";
        private const string DescriptionItem = "description";

        [ConfigurationProperty(NameItem, IsKey = true, IsRequired = true)]
        public virtual string Name
        {
            get { return base[NameItem] as string; }
        }

        [ConfigurationProperty(DescriptionItem, IsKey = false, IsRequired = false)]
        public virtual string Description
        { get { return base[DescriptionItem] as string; } }
    }

    /// <summary>
    /// Dal provider
    /// </summary>
    public class DALProviderConfigurationElement : NamedConfigurationElementBase
    {
        private const string PathItem = "path";
        private const string NamespaceItem = "namespace";
        private const string ConnectionStringItem = "connectionString";

        [ConfigurationProperty(PathItem, IsKey = false, IsRequired = true)]
        public string Path
        { get { return base[PathItem] as string; } }

        [ConfigurationProperty(NamespaceItem, IsRequired = true)]
        public string Namespace
        {
            get { return base[NamespaceItem] as string; }
        }

        [ConfigurationProperty(ConnectionStringItem, IsRequired = false)]
        public string ConnectionString
        {
            get { return base[ConnectionStringItem] as string; }
        }
    }
}